<template>
  <div >
    <ComponentCard title="今日销售额" :value="numberFormat(salesToday)">
      <template #default>
        <div class="compare">
          <div class="emphasis">日同比 {{salesGrowthLastDay}}&nbsp;<span class="decrement"></span></div>
          <div class="emphasis">月同比 &nbsp;{{salesGrowthLastMonth}} &nbsp;<span class="increment"></span></div>
        </div>
      </template>
      <template #footer>
        <div>昨日销售额<span >{{moneyFormat(salesLastDay)}}</span></div>
      </template>
    </ComponentCard>
  </div>
</template>

<script lang="ts">
export default {
  name: "monitor"
};
</script>
<script lang="ts" setup>
import ComponentCard from "./ComponentCard.vue";
import {useReportStore} from "@/stores/reportData";
import { computed } from "vue";
import useFormat from "@/hooks/useFormat";
const reportDataStore = useReportStore()
const {numberFormat,moneyFormat} = useFormat()  //格式化数据
// 计算属性处理数据
// 1.计算销售额
const salesToday = computed(()=>reportDataStore.reportData.salesToday)
// 2.昨日销售额
const salesLastDay = computed(()=>reportDataStore.reportData.salesLastDay)
// 3.日同比
const salesGrowthLastDay = computed(()=>reportDataStore.reportData.salesGrowthLastDay)
// 4.月同比
const salesGrowthLastMonth = computed(()=>reportDataStore.reportData.salesGrowthLastMonth)
</script>
<style lang="scss" scoped>
.compare {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  >div {
    display: flex;
    align-items: center;
  }
}
</style>